package com.letv.core.bean;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * 上传文件
 */
public class UploadFileBean {
    /* 上传文件的数据 */
    private byte[] mData;
    private InputStream mInStream;
    private File mFile;
    /* 文件名称 */
    private String mFilname;
    /* 请求参数名称 */
    private String mParameterName;
    /* 内容类型 */
    private String mContentType = "application/octet-stream";

    public UploadFileBean(String filname, byte[] data, String parameterName, String contentType) {
        this.mData = data;
        this.mFilname = filname;
        this.mParameterName = parameterName;
        if (contentType != null)
            this.mContentType = contentType;
    }

    public UploadFileBean(File file, String parameterName, String contentType) {
        this.mFilname = file.getName();
        this.mParameterName = parameterName;
        this.mFile = file;
        try {
            this.mInStream = new FileInputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        if (contentType != null)
            this.mContentType = contentType;
    }

    public File getFile() {
        return mFile;
    }

    public InputStream getInStream() {
        return mInStream;
    }

    public byte[] getData() {
        return mData;
    }

    public String getFilname() {
        return mFilname;
    }

    public void setFilname(String filname) {
        this.mFilname = filname;
    }

    public String getParameterName() {
        return mParameterName;
    }

    public void setParameterName(String parameterName) {
        this.mParameterName = parameterName;
    }

    public String getContentType() {
        return mContentType;
    }

    public void setContentType(String contentType) {
        this.mContentType = contentType;
    }

}
